#ifndef TABDIALOG_H
#define TABDIALOG_H
/*
 *  cpu_gui/tabdialog.h
 *  
 *              CPU Monitor 
 *
 *    Spring Semester.  044800.    Technion.
 *   Copyright (C) 2006  Evgeny Shulman  and Elizabeth Shtrom 
 */

#include <QTreeView>
#include <QStandardItemModel>
#include <QDialog>
#include <QButtonGroup>
#include <QLCDNumber>
#include <QLabel>

#include "w_pagew.h"
#include "w_im_man.h"
#include "w_cpuid.h"
#include "w_regw.h"
#include "../cpu_consts.h"

 extern int fd[8];
 
 class QDialogButtonBox;
 class QFileInfo;
 class QTabWidget;


 /******************** Regs Tab **********************/
 class RegsTab : public MonitorPageTab
 {
 	Q_OBJECT
 public:
     RegsTab(QWidget *parent = 0);
 public slots:
 	int show_values(void);
 private:
    RegWin *regs_win_cr;
    RegWin *regs_win_db;
    RegWin *regs_win_sg;
    RegWin *regs_win_gdtr;
    RegWin *regs_win_idtr;
    RegWin *regs_win_tr;
    regs_s regs;
 };

 /******************** Gdt Tab **********************/
 class GdtTab : public MonitorPageTab
 {
    Q_OBJECT

 public:
    GdtTab(QWidget *parent = 0);
    QTreeView * tView;
 public slots:
    int show_values(void);
    

 private:
    QAbstractItemModel *ListHeader;
	  cm_desc_t gdt_table[GDT_ENTRIES];
 };
 
 /******************** Ldt Tab **********************/
 class LdtTab : public MonitorPageTab
 {
    Q_OBJECT

 public:
    LdtTab(QWidget *parent = 0);
    QTreeView * tView;

 public slots:
 	int show_values(void);
 	
 private:
 		QLabel *Status;
    QAbstractItemModel *ListHeader;
    cm_desc_t ldt_table[LDT_ENTRIES];
 };

 /******************** Tss Tab **********************/
class TssTab : public MonitorPageTab
{
    Q_OBJECT
public:
    TssTab(QWidget *parent = 0);
    QTreeView * tView;
public slots:
  int show_values(void);

private:
    QAbstractItemModel *ListHeader;
    cm_tss_struct tss_table;
 };

 /******************** Idt Tab **********************/
 class IdtTab : public MonitorPageTab
 {
    Q_OBJECT
public:
    IdtTab(QWidget *parent = 0);
    QTreeView * tView;
public slots:
 	int show_values(void);
 	
private:
	QAbstractItemModel *ListHeader;
	cm_gate_desc_t idt_table[IDT_ENTRIES];
 };

  /******************** PageTable Tab **********************/
class PageTableTab :public MonitorPageTab
{
    Q_OBJECT

public:
    PageTableTab(QWidget *parent = 0);
    QTreeView * tView;
public slots:
	int show_values(void);
    void set_pt_entry( unsigned long entry );
	void update_curr_cpu(int cpu_num);
	
private:
    unsigned long Entry;
    QTreeView * PtDirView;
    QAbstractItemModel *ListHeader;
    QLabel *Status;
    unsigned long pt_table[PT_TABLE_ENTRIES];
 };

 /******************** PageDir Tab **********************/
class PageDirTab : public MonitorPageTab
 {
    Q_OBJECT

 public:
    PageDirTab(  QWidget *parent = 0);
    QTreeView * tView;
 signals:
 	void ptDoubleClicked(unsigned long);
 public slots:
	int show_values(void);
	void emit_ptDoubleClicked(const QModelIndex &index);
	
 private:
    QAbstractItemModel *ListHeader;
    QAbstractItemView * Item;
    PageTableTab * PgTable;
    unsigned long pgdir_table[PGD_TABLE_ENTRIES];
 };
 

 /******************** Main WindoW **********************/
 class MyWidget : public QWidget
 {
     Q_OBJECT

 public:
     int nrCPUs;
     MyWidget(const int _nrCPUs , const cpu_set_t  _affinityModeDefault, QWidget *parent =0 );
  public slots:
     void refresh();
	 void set_show_pt (unsigned long entry);
	 void show_idt  (void);
	 void show_idt_monitor(void);
 private:
	QButtonGroup * ButtonGroup;
	QTabWidget * tabWidget;
	
	QGroupBox*    MyWidget::build_pid (  const QString &str, QLabel **pid_lb_p);
	
	RegsTab * Regs;
	GdtTab * Gdt;
	LdtTab * Ldt;
	TssTab * Tss;
	IdtTab * Idt;
	CpuidTab   *CpuId;
	PageDirTab * PgDir;
	PageTableTab * PgTable;
	ImWindow * Idt_monitor;
	
	QLabel *mainPid_lb;
	QLabel *dataPid_lb;
	QLabel *affinity_lb;
	QButtonGroup *af_ButtonGroup;
	int isAffinityMode, isAffinityModeChanged ;
	cpu_set_t affinityModeDefault;
	
 };


 #endif
